package top.yxqz.servelt;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author Mr.余
 * @date 2022/11/15
 * @package top.yxqz.servelt
 *
 * Servlet3.0规范学习
 * 使用注解，只有一个属性的的情况下，设置的值，默认是给value属性的值
 * 设置多个属性的值，使用逗号分割，并且使用等号赋值
 * 使用注解，不给Servelt的name赋值，默认是该servlet的全类名路径
 */
@WebServlet(value = "/servlet1",name = "servlet01")
public class ServletDemo01 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        PrintWriter writer = response.getWriter();
        writer.println("hello world");

        ServletConfig config = getServletConfig();
        String servletName = config.getServletName();
        writer.println("servletName:"+servletName);


        ServletContext context = config.getServletContext();

    }
}
